
import { DoublyLinkedList } from "./doublyLinkedList.js";

// -------------- 封装的双向链表结构测试 ---------------//
alert("双向链表结构测试 START");
const doublyLinkedList = new DoublyLinkedList();

// append() 测试
alert("append 测试");
doublyLinkedList.append("ZZ");
alert("append ZZ");
alert(doublyLinkedList);
doublyLinkedList.append("XX");
alert("append XX");
alert(doublyLinkedList);
doublyLinkedList.append("CC");
alert("append CC");
alert(doublyLinkedList);

// insert() 测试
alert("insert 测试");
doublyLinkedList.insert(0,"00");
alert("insert o,'00'");
alert(doublyLinkedList);
doublyLinkedList.insert(2,"22");
alert("insert 2,'22'");
alert(doublyLinkedList);

// getData() 测试
alert("getData(1) 测试");
alert(doublyLinkedList.getData(1));

// indexOf() 测试
alert("indexOf('XX') 测试");
alert(doublyLinkedList.indexOf("XX"));
alert(doublyLinkedList);

// removeAt() 测试
alert("removeAt() 测试");
doublyLinkedList.removeAt(0);
alert("removeAt(0)");
alert(doublyLinkedList);
doublyLinkedList.removeAt(1);
alert("removeAt(1)");
alert(doublyLinkedList);

// update() 测试
alert("update(1,'111111') 测试");
doublyLinkedList.update(1,"111111");
alert(doublyLinkedList);

// remove() 测试
alert("remove('111111') 测试");
alert(doublyLinkedList.remove("111111"));
alert(doublyLinkedList);

// forwardToString() 测试
alert("forwardToString() 测试");
alert(doublyLinkedList.forwardToString());

// backwardString() 测试
alert("backwardString() 测试");
alert(doublyLinkedList.backwardString());

alert("双向链表测试 END");
